class Person:
    def __init__(self, name, gender, age, phone):
        self.__name = name
        self.__gender = gender
        self.__age = age
        self.__phone = phone
        self.__credits = 0

    # Getter和Setter方法
    def get_name(self):
        return self.__name

    def get_gender(self):
        return self.__gender

    def get_age(self):
        return self.__age

    def get_phone(self):
        return self.__phone

    def get_credits(self):
        return self.__credits

    def set_name(self, name):
        self.__name = name

    def set_gender(self, gender):
        self.__gender = gender

    def set_age(self, age):
        self.__age = age

    def set_phone(self, phone):
        self.__phone = phone

    # 发短信方法
    def send_sms(self, content):
        print(f"{self.__name}正在发送短信: {content}")

    # 打电话方法
    def make_call(self, phone_number, duration):
        if not phone_number:
            print("错误: 电话号码不能为空")
            return

        if self.__phone.get_balance() < 1:
            print("错误: 话费不足，无法拨打电话")
            return

        print(f"{self.__name}正在拨打 {phone_number}，通话时长 {duration} 分钟")

        # 计算费用和积分
        if duration <= 10:
            cost_per_minute = 1.0
            credits_per_minute = 15
        elif duration <= 20:
            cost_per_minute = 0.8
            credits_per_minute = 39
        else:
            cost_per_minute = 0.65
            credits_per_minute = 48

        total_cost = duration * cost_per_minute
        total_credits = duration * credits_per_minute

        # 扣除话费并增加积分
        self.__phone.deduct_balance(total_cost)
        self.__credits += total_credits

        print(f"通话结束，扣除话费 {total_cost} 元，获得积分 {total_credits}")


class Phone:
    def __init__(self, brand, battery_capacity, screen_size, max_standby_time, initial_balance=0):
        self.__brand = brand
        self.__battery_capacity = battery_capacity
        self.__screen_size = screen_size
        self.__max_standby_time = max_standby_time
        self.__balance = initial_balance

    # Getter和Setter方法
    def get_brand(self):
        return self.__brand

    def get_battery_capacity(self):
        return self.__battery_capacity

    def get_screen_size(self):
        return self.__screen_size

    def get_max_standby_time(self):
        return self.__max_standby_time

    def get_balance(self):
        return self.__balance

    def set_brand(self, brand):
        self.__brand = brand

    def set_battery_capacity(self, battery_capacity):
        self.__battery_capacity = battery_capacity

    def set_screen_size(self, screen_size):
        self.__screen_size = screen_size

    def set_max_standby_time(self, max_standby_time):
        self.__max_standby_time = max_standby_time

    def deduct_balance(self, amount):
        if amount > self.__balance:
            print("错误: 余额不足")
            return False
        self.__balance -= amount
        return True

    def add_balance(self, amount):
        self.__balance += amount


# 测试代码
if __name__ == "__main__":
    # 创建手机对象
    phone = Phone("小米", 5000, 6.5, 72, 100)  # 品牌，电池容量，屏幕大小，最大待机时间，初始话费

    # 创建人物对象
    person = Person("张三", "男", 30, phone)

    # 显示初始信息
    print(f"用户信息: {person.get_name()}，{person.get_gender()}，{person.get_age()}岁")
    print(f"手机信息: {phone.get_brand()}，电池容量{phone.get_battery_capacity()}mAh")
    print(f"当前话费: {phone.get_balance()}元，当前积分: {person.get_credits()}")

    # 测试发短信
    person.send_sms("今天天气不错！")

    # 测试打电话（5分钟）
    person.make_call("13800138000", 5)
    print(f"剩余话费: {phone.get_balance()}元，当前积分: {person.get_credits()}")

    # 测试长时间通话（25分钟）
    person.make_call("13900139000", 25)
    print(f"剩余话费: {phone.get_balance()}元，当前积分: {person.get_credits()}")

    # 测试话费不足的情况
    phone.deduct_balance(phone.get_balance() - 0.5)  # 将话费减少到0.5元
    person.make_call("13700137000", 10)